{include file="public/header" /}
<body class="gray-bg">
<div class="wrapper wrapper-content">
    <div class="row">
        <div class="col-sm-12">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <h5>编辑型号</h5>
                </div>
                <div class="ibox-content layui-form">
                    <div class="layui-row layui-col-space10 layui-form-item ">

                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                            <label class="layui-form-label">型号名称：</label>
                            <div class="layui-input-block">
                                <input type="text" name="models_name" lay-verify="required" placeholder="型号名称" class="layui-input" value="{$models.models_name}">
                            </div>
                        </div>

                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                            <label class="layui-form-label">型号全名称：</label>
                            <div class="layui-input-block">
                                <select name="models_all_name"  xm-select="select1" xm-select-search="" xm-select-search-type="dl" xm-select-radio="" lay-verify="required">
                                    {foreach name="model" item="vo1"}
                                    <option value="{$vo1.mn_name}" {$vo1.mn_name == $models.models_all_name ? 'selected' : ''}>{$vo1.mn_name}</option>
                                    {/foreach}
                                </select>
                            </div>
                        </div>

                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                            <label class="layui-form-label">缩略图：</label>
                            <input type="hidden" name="models_image" id="lay-img" lay-verify="image" value="{$models.models_image}">
                            <div class="layui-input-block">
                                <div id="lay-upload">上传图片</div>
                                <blockquote class="layui-elem-quote layui-quote-nm" style="margin-top: 10px;">
                                    预览图：
                                    <div class="layui-upload-list" id="lay-list">
                                        <img class="layui-append-img" src="{$models.models_image}" onerror="this.src='/static/admin/images/no_img.jpg'">
                                    </div>
                                </blockquote>
                            </div>
                        </div>

                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                            <label class="layui-form-label">分类：</label>
                            <div class="layui-input-block">
                                <select name="models_cate_id"  xm-select="select" xm-select-search="" xm-select-search-type="dl" xm-select-radio="" lay-verify="required">
                                    {foreach name="cate" item="vo"}
                                    <option value="{$vo.cate_id}" {$vo.cate_id == $models.models_cate_id ? 'selected' : ''}>{$vo.cate_name}</option>
                                    {/foreach}
                                </select>
                            </div>
                        </div>

                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                            <label class="layui-form-label">原价：</label>
                            <div class="layui-input-block">
                                <input type="text" name="models_prime_price" lay-verify="required" placeholder="原价" class="layui-input" oninput="value=value.replace(/^(0+)|[^\d.]/g,'')" value="{$models.models_prime_price}">
                            </div>
                        </div>

                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                            <label class="layui-form-label">最高回收价格：</label>
                            <div class="layui-input-block">
                                <input type="text" name="models_max_recycle_price" lay-verify="required" placeholder="最高回收价格" class="layui-input" oninput="value=value.replace(/^(0+)|[^\d.]/g,'')" value="{$models.models_max_recycle_price}">
                            </div>
                        </div>

                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                            <label class="layui-form-label">颜色：</label>
                            <div class="layui-input-block">
                                <textarea name="models_color" lay-verify="required" placeholder="颜色" class="layui-textarea">{$models.models_color}</textarea>
                            </div>
                        </div>

                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                            <label class="layui-form-label">排序：</label>
                            <div class="layui-input-block">
                                <input type="text" name="models_sort" lay-verify="required" placeholder="排序" class="layui-input" oninput="value=value.replace(/[^\d]/g,'')" value="{$models.models_sort}">
                            </div>
                        </div>

                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8 form-group">
                            <label class="layui-form-label">状态：</label>
                            <div class="layui-input-block">
                                <input type="radio" name="models_status" value="1" title="上架" {$models.models_status == 1 ? 'checked' : ''}>
                                <input type="radio" name="models_status" value="2" title="下架" {$models.models_status == 2 ? 'checked' : ''}>
                            </div>
                        </div>

                        <input type="hidden" value="{$models_id}" name="models_id">

                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                            <div class="layui-input-block">
                                <button class="layui-btn" lay-submit="" lay-filter="component-form-element">保存
                                </button>
                                <button class="layui-btn layui-btn-primary" onclick="history.go(-1)">关闭</button>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
{include file="public/footer" /}

<script>
    wk.uploadImg({size:2,type:'png,jpg,jpeg',url:"{:url('Upload/upload')}",domain:""});
    layui.use(['form','upload','layedit'], function() {
        var form = layui.form;
        form.on('submit(component-form-element)', function (data) {
            $('.layui-btn').addClass('layui-disabled').attr('disabled','disabled');
            $.ajax({
                url:"{:url('modelEdit')}",
                type:'post',
                dataType:'json',
                data:data.field,
                success:function(res){
                    if (res.code == 200) {
                        wk.success(res.msg,"{:url('Brand/modelList')}");
                    } else {
                        wk.error(res.msg,'','$(".layui-btn").removeClass(\'layui-disabled\').removeAttr(\'disabled\');');
                    }
                }
            })
        });
    });
</script>

</body>
</html>
